using System;
using System.IO;

namespace SubConvert.Core
{
    public static class SpecialWriter
    {
        private static string logFilePath;

        static SpecialWriter()
        {
            //stream = File.CreateText(@"c:\subconvert.log");//default log file    
        }

        public static void SetLogFile(string newLogFilePath)
        {
            logFilePath = newLogFilePath;
        }

        public static void WriteLine(string format, params object[] args)
        {
            using(var stream = StreamWriter())
            {
                stream.WriteLine(format,args);
            }
            Console.WriteLine(format, args);
        }

        private static StreamWriter StreamWriter()
        {
            return File.Exists(logFilePath) ? File.AppendText(logFilePath) : File.CreateText(logFilePath);
        }

        public static void WriteLine(string input)
        {
            using(var stream = StreamWriter())
            {
                stream.WriteLine(input);
            }
            Console.WriteLine(input);
        }
    }
}